
<template>
    <div class="app-container">
        <el-row :gutter="20">
            <!--部门数据-->
            <el-col :span="4" :xs="24">
                <fileTrees @handleNodeClick="onTreeClick" :tableHeight="treeHeight" :isnoClick="isnoClick" :menuId="menuId">
                </fileTrees>
            </el-col>
            <!--离线接收数据-->
            <el-col :span="20" :xs="24" v-show="isShow">
                <queryCriteriaList v-if="listFrom.length > 0" :showSearch="showSearch" :listFrom="listFrom"
                    @resetQuery="resetQuery" @handleQuery="handleQuery" ref="queryForm"></queryCriteriaList>
                <el-row :gutter="10" class="mb8" ref="refbut">
                    <el-col :span="1.5"
                        v-show="(subStr == 'X' && categoryType == '3') || (subStr == 'V' && categoryType == '1') || (subStr == 'F' && categoryType == '0')">
                        <el-button type="primary" plain icon="el-icon-takeaway-box" v-hasPermi="['archive:zxjs:jieshou']"
                            @click="handleJieshouTap()">接收</el-button>
                    </el-col>
                    <el-col :span="1.5"
                        v-show="(subStr == 'X' && categoryType == '3') || (subStr == 'V' && categoryType == '1') || (subStr == 'F' && categoryType == '0')">
                        <el-button type="primary" plain icon="el-icon-takeaway-box" v-hasPermi="['archive:lxjs:jieshou2']"
                            @click="handleJieshouTap2()">接收至待归档</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <!--案卷著录-->
                        <el-button type="primary" plain icon="el-icon-plus" v-show="(subStr == 'V')"
                            @click="handledeitTap(0)" v-hasPermi="['archive:zxjs:addFolder']">著录</el-button>
                        <!--件著录-->
                        <el-button type="primary" plain icon="el-icon-plus" v-show="(subStr == 'F')"
                            @click="handledeitTap(0)" v-hasPermi="['archive:zxjs:addYqda']">著录</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="success" plain icon="el-icon-edit" @click="handledeitTap(1)">修改</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="danger" plain icon="el-icon-delete" @click="handleDeleteTap()">退回</el-button>
                    </el-col>
<!--                  <el-col :span="1.5">
                    &lt;!&ndash; v-hasPermi="['archive:zjsj:sxjc']" &ndash;&gt;
                    <el-button type="primary" icon="el-icon-takeaway-box" @click="handleSXJCTap()" >四性检测</el-button>
                  </el-col>-->
                    <el-col :span="1.5" v-show="subStr == 'V' && categoryType == '1' && storeType == 'j'">
                        <el-button type="warning" plain icon="el-icon-document"
                            @click="handleInfoDetailTap()">案件信息</el-button>
                    </el-col>
                    <el-col :span="1.5" v-show="subStr == 'F' && (categoryType == 1 || categoryType == 3)">
                        <!--组件类型档案不展示组卷按钮-->
                        <el-button type="primary" icon="el-icon-files" @click="mergeYqdaTap(1)"
                            v-hasPermi="['archive:zxjs:mergeYqda']">组卷</el-button>
                    </el-col>
<!--                    <el-col :span="1.5"
                        v-show="subStr == 'F' && (categoryType == 1 || categoryType == 3 || categoryType == 0)">
                        <el-upload multiple action="" :http-request="uploadFileUrl" :before-upload="handleBeforeUpload"
                            :on-error="handleUploadError" :on-exceed="handleExceed" :show-file-list="false"
                            class="upload-file-uploader" ref="fileUpload">
                            <el-button class="upload_btn" type="primary" icon="el-icon-upload"
                                style="height: 37px">上传归档包</el-button>
                        </el-upload>
                    </el-col>-->

                    <right-toolbar :showSearch.sync="showSearch" @queryTable="queryTableTap"></right-toolbar>
                </el-row>
                <tableList v-if="tableHeight" :tableHeaderList="tableHeaderList"
                    @handleSelectionChange="handleSelectionChange" :tableData="tableData" :loading="loading"
                    :tableHeight="tableHeight" @celldblclick="celldblclick" @sortChange="sortChange" ref="ref"></tableList>
                <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize" @pagination="getlistPost" />
            </el-col>
            <el-col :span="20" :xs="24" v-show="!isShow" class="empty">
                <el-empty :image-size="200"></el-empty>
            </el-col>

        </el-row>
        <!-- start 组件著录、修改 -->
        <jiandeit v-if="jianOpen" :open="jianOpen" :openInfo="openInfo" @closeDelDialog="closeDelDialog"
            @submitDetail="submitDetail" :isParams="6">
        </jiandeit>
        <!-- end  组件著录、修改-->

        <!-- start 组卷著录、修改 -->
        <juandeit v-if="juanOpen" :open="juanOpen" :openInfo="openInfo" @closeDelDialog="closeDelDialog"
            @submitDetail="submitDetail" :isParams="6" isType="online"></juandeit>
        <!-- end  组卷著录、修改-->

        <!-- start 项目著录  修改 -->
        <projectdeit v-if="projectOpen" :open="projectOpen" :openInfo="openInfo" @submitDetail="submitDetail"
            @closeDelDialog="closeDelDialog" :isParams="6"></projectdeit>
        <!-- end 项目著录、修改 -->

        <!--start  组件详情 -->
        <jianDetailsOpen v-if="jianDetailsOpen" :open="jianDetailsOpen" :celldbData="celldbData"
            @detailsHandleClose="detailsHandleClose">
        </jianDetailsOpen>
        <!--end 组件详情 -->
        <!-- start 组卷\项目详情 -->
        <juanDetailsOpen v-if="juanDetailsOpen" :open="juanDetailsOpen" :celldbData="celldbData"
            @detailsHandleClose="detailsHandleClose"></juanDetailsOpen>
        <!-- end 组卷\项目详情 -->

        <!-- 案件信息 -->
        <InformationDetail :info="info" @infoCancelTap="infoCancelTap" ref="infoRef"></InformationDetail>

      <!-- start  检测方案弹窗 -->
      <el-dialog title="请选择检测方案" :visible.sync="dialogVisible" width="20%" :before-close="handlecloseDelDialog"
                 :close-on-click-modal="false">
        <el-select v-model="sxjcType" placeholder="请选择" style="width:100%">
          <el-option v-for="item in sxjcList" :key="item.identification" :label="item.identification"
                     :value="item.identification">
          </el-option>
        </el-select>
        <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="handleYes">确 定</el-button>
            </span>
      </el-dialog>
      <!-- end  检测方案弹窗-->
    </div>
</template>
<script>
import {
    getqueryfieldList,
    getlistbytreenodeList,
    getthbytreenodeHeaderList,
    deleteData,
    jieshou,
    jieshou2,
    assemblyFolderVerify
} from "@/api/archive/fileCollection/offlinReception.js";
import { fileUpload,ygdDetection } from "@/api/archive/fileCollection/onlineReception.js";
import { getInfo } from "@/api/login";
import queryCriteriaList from "@/components/queryCriteriaList/index.vue"  //查询列表
import fileTrees from "@/components/fileTrees/index.vue"  //档案树
import { getGroupTree } from "@/api/archive/archivesCategory.js"
import tableList from "@/components/tableList/index2.vue"
import jiandeit from "@/views/archive/fileCollection/offlinReception/jiandeit.vue" //件添加修改弹窗
import juandeit from "@/views/archive/fileCollection/offlinReception/juandeit.vue" //卷添加修改弹窗
import projectdeit from "@/views/archive/fileCollection/offlinReception/projectdeit.vue" //卷添加修改弹窗
import treeHeight from '@/mixins/treeHeight'//计算左侧树的高度
import jianDetailsOpen from '@/components/componentsJianDetails/index.vue' //件详情
import juanDetailsOpen from '@/components/componentsJuanDetails/index.vue' //卷详情'
import { getdetectionSchemeList } from '@/api/archive/archiveTransfer/archiveTransfer.js'
import { getLastIndexOf } from "@/utils/index.js"
import InformationDetail from "@/views/archive/digitalizeReceive/archiveReception/informationDetail";
import { getDicts_archive } from "@/api/homePage";
import {getRouters} from "@/api/menu";
export default {
    mixins: [treeHeight], // 混入方法
    components: {
        InformationDetail,
        queryCriteriaList,
        fileTrees,
        jiandeit,
        juandeit,
        tableList,
        projectdeit,
        jianDetailsOpen,
        juanDetailsOpen
    },
    data() {
        return {
            userId: '',
            chunkSize: 20,
            menuId: '',
            isnoClick: true, //防止树重复点击
            scroll: "",
            loading: false,
            // 显示搜索条件
            showSearch: true,
            listFrom: [], //查询框列表
            isShow: false, //是否显示右侧数据
            categoryinfo: "", //档案门类回显信息
            total: 0,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
            tableHeaderList: [], //table表头数据
            tableData: [],//table列表数据
            jianOpen: false, //组件打开关闭
            juanOpen: false, //组卷打开关闭
            projectOpen: false,//项目打开关闭
            jianDetailsOpen: false,//件详情弹窗
            juanDetailsOpen: false,//卷详情弹窗
            openInfo: { //件 卷  项目
                opens: false,
                categoryId: undefined,
                menuId: undefined,
                type: undefined
            },
            tableHeight: "",
            ids: undefined,
            oagdbss:undefined,
            single: "",
            multiple: true,
            rowList: "", //当前点击的数据
            subStr: "",  //获取点击当前树的 件 卷  项目 截取 sub_table_name显示
            categoryType: "",
            storeType: '',  // 门类类型
            // 案件信息
            info: {
                // 是否显示弹出层
                open: false,
            },
            dictList: [],
            // 路由地址
            routeList: [],
          sxjcList: [],//四性检测方案列表数据
          sxjcType: undefined,
          dialogVisible: false, //检测方案弹窗
        }
    },

    created() {
        this.menuId = this.$route.meta.menuId;

        this.getConfigKey("CHUNK_SIZE").then(response => {
            if (response.msg == '') {
                this.chunkSize = 20
            } else {
                this.chunkSize = response.msg;
            }
        });
        getInfo().then(response => {
            this.userId = response.user.userId
        })

        getRouters().then(res => {
          this.routeList = res.data
        })
    },


    methods: {
        //动态设置table的高度
        tableHeightData() {
            this.$nextTick(
                () => {
                    let h = document.documentElement.clientHeight
                    //     console.log(this.$refs.queryForm.$el.offsetHeight, this.$refs.refbut.$el.offsetHeight, "sdklfjklliuhaiorng")
                    h = h - 200
                    if (this.$refs.queryForm) { // 页面上如果有面包屑区域徐减去它的高度
                        h = h - this.$refs.queryForm.$el.offsetHeight
                    }

                    if (this.$refs.refbut) { // 页面上如果有分页区域徐减去它的高度
                        h = h - this.$refs.refbut.$el.offsetHeight
                    }
                    // console.log(h,"sdjfdklsjfkl")
                    this.tableHeight = h > 310 ? h : 310 // 根据自己项目定高度
                    return h
                }
            )

        },


        // 树节点单击事件
        onTreeClick(data) {
            console.log(data, "+++")
            this.isnoClick = false;
            this.treeRowData = data;
            if (data.categoryId != null) {
                this.isShow = true
            } else {
                this.isShow = false
            }
            if (this.$refs.queryForm != undefined) {
                this.$refs.queryForm.queryParams = {};
            }
            if (data.nodeType == null || data.nodeType == "t" || data.nodeType == "f") {
                this.isnoClick = true;
                return false;
            }
            this.loading = true;
            this.queryParams = data;
            this.queryParams.state = 1;
            this.queryParams.jsType = 1;
            this.queryParams.pageNum = 1;
            this.queryParams.pageSize = 10;
            this.queryParams.order = '';
            if (this.queryParams.sub_table_name != undefined) {
                this.subStr = getLastIndexOf(this.queryParams.sub_table_name);
                let stb = this.queryParams.sub_table_name;
                let stbArr = stb.split("_");
                this.categoryType = stbArr[stbArr.length - 3];
            } else {
                this.getGroupTreePost(data.categoryId);
            }
            this.getqueryfieldListPost();//点击树节点获取查询字段
            this.getlistHeaderPost();/**点击树节点,获取table表头数据 */
            if (this.$refs.ref != undefined) {
                this.$refs.ref.clearSort()
            }
        },


        //档案门类树门类根据categoryID回显
        getGroupTreePost(ID) {
            getGroupTree(ID).then(response => {
                if (response.data.type == "0") { //件
                    this.queryParams.sub_table_name = response.data.fileTableName;
                } else if (response.data.type == "1") { //卷
                    this.queryParams.sub_table_name = response.data.folderTableName;
                } else { //项目
                    this.queryParams.sub_table_name = response.data.itemTableName;
                }
                this.subStr = getLastIndexOf(this.queryParams.sub_table_name);
                let stb = this.queryParams.sub_table_name;
                let stbArr = stb.split("_");
                this.categoryType = stbArr[stbArr.length - 3];
                this.storeType = response.data.storeType
            });
        },

        /** 点击树节点获取查询字段 */
        getqueryfieldListPost(data) {
            this.queryParams.searchcolumn = undefined
            getqueryfieldList({
                categoryId: this.queryParams.categoryId,
                menuId: this.queryParams.menuId,
                subTableName: this.queryParams.sub_table_name,

            }).then(response => {
                this.listFrom = response.rows;
            });
        },
        /**点击树节点,获取table表头数据 */
        getlistHeaderPost() {
            getthbytreenodeHeaderList({
                categoryId: this.queryParams.categoryId, menuId: this.queryParams.menuId, subTableName: this.queryParams.sub_table_name
            }
            ).then(response => {
                this.tableHeaderList = response.rows;
                var fields = []
                for (var i in response.rows) {
                    fields.push(response.rows[i].FIELD_NAME)
                }
                this.queryParams.fields = fields.toString()
                this.getlistPost();
                this.isnoClick = true;
            });
        },
        /** 点击树节点,获取table数据*/
        getlistPost() {
            if (this.queryParams.fields==''){
              this.$message({ message: '请先对该门类进行配置！', type: 'warning' })
              return ;
            }
            getlistbytreenodeList(this.queryParams).then(response => {
                this.tableData = response.rows;
                this.total = response.total;
                this.loading = false;
                this.tableHeightData();
                // this.isnoClick = true;
            });
        },

        //是否选择数据
        handleSelectionChange(ids, oagdbs,single, multiple) {
            this.ids = ids.toString();
            this.oagdbss =  oagdbs.toString();
            this.single = single;
            this.multiple = multiple;
        },

        //表单重置
        resetQuery() {
            this.queryParams.searchcolumn = undefined
            this.queryParams.order = undefined;
            this.getlistPost();
            this.$refs.ref.clearSort()
        },
        //点击搜索
        handleQuery(searchcolumn) {

            var column = searchcolumn.filter(item => { return item.value !== '' && item.value !== null })
            this.queryParams.searchcolumn = column
            this.queryParams.order = undefined;
            this.getlistPost();
            this.$refs.ref.clearSort()
        },
        //刷新页面
        queryTableTap() {
            this.queryParams.order = undefined;
            this.getlistPost();
            this.$refs.ref.clearSort()
        },

        //件  this.jianOpen  著录和修改     //组卷 this.juanOpen 著录和修改    //项目 this.projectdOpen 著录和修改
        handledeitTap(e) {
            this.openInfo = {
                opens: true,
                categoryId: this.queryParams.categoryId,
                menuId: this.queryParams.menuId,
                folderId: undefined, //组卷id
                itemId: undefined, //项目Id
                subTableName: this.queryParams.sub_table_name,
                nodeType: this.queryParams.nodeType,
                parentNodeType: this.queryParams.parentNodeType,
                parentSubTableName: this.queryParams.parentSubTableName,
                subStr: this.subStr,
            }
            if (e == 1) {  //修改
                if (this.ids == undefined) {
                    this.$message({ message: '请选择要修改的数据哦', type: 'warning' })
                    return false
                }
                if (this.single) {
                    this.$message({ message: '请选择一条要修改的数据哦', type: 'warning' })
                    return false
                }

                this.openInfo.ids = this.ids; //组件Id;
            } else { //添加
                this.openInfo.ids = undefined
            }
            if (this.subStr == "F") {  //F 件
                this.openInfo.type = 0
                this.jianOpen = true
            } else if (this.subStr == "V") { //卷
                this.openInfo.type = 1
                this.juanOpen = true;
            } else { //项目
                this.openInfo.type = 3
                this.projectOpen = true;
            }
        },
        //给项目案卷著录
        handledeitanJuanTap() {
            this.openInfo = {
                opens: true,
                categoryId: this.queryParams.categoryId,
                menuId: this.queryParams.menuId,
                type: 1, //传卷类型  0,组件 1，组卷 3，项目
                folderId: undefined, //组卷id
                itemId: undefined, //项目Id
                subTableName: this.queryParams.sub_table_name
            }
            console.log(this.openInfo)
            if (this.ids == undefined) {
                this.$message({ message: '请选择先选择数据哦', type: 'warning' })
                return false
            }
            if (this.single) {
                this.$message({ message: '请选择一条数据哦', type: 'warning' })
                return false
            }
            this.openInfo.itemId = this.ids; //项目Id;
            this.juanOpen = true;
        },

        //关闭著录 \件\ 组卷
        closeDelDialog() {
            this.jianOpen = false //件
            this.juanOpen = false //卷
            this.projectOpen = false; //项目
            this.openInfo = ""
        },

        //著录成功
        submitDetail() {
            this.jianOpen = false;
            this.juanOpen = false //卷
            this.projectOpen = false; //项目
            this.getlistHeaderPost();
        },
        //删除
        handleDeleteTap() {
          console.log(this.ids);
            if (this.ids != undefined && !this.multiple) {
              this.$prompt('请输入退回原因', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /.*/, // 允许任意输入
                inputErrorMessage: '输入不能为空'
              }).then(({ value }) => {
                // 用户点击了确定，并输入了内容
                let type = "";
                if (this.subStr == "F") {  // F 件
                  type = 0;
                } else if (this.subStr == "V") { // 卷
                  type = 1;
                } else { // 项目
                  type = 3;
                }

                deleteData({
                  type: type,
                  categoryId: this.queryParams.categoryId,
                  ids: this.ids,
                  remark: "nfOaTongZhi",
                  oagdbss: this.oagdbss,
                  tuiHuiShuoMing: value // 将用户输入的原因传递给后端
                }).then(res => {
                  if (res.code == "200") {
                    this.$modal.msgSuccess("退回成功");
                    this.getlistPost();
                  }
                });
              }).catch(() => {
                // 用户点击了取消或关闭弹窗
                this.$message({
                  type: 'info',
                  message: '取消操作'
                });
              });
            } else {
                this.$message({ message: '请选择要删除的数据哦', type: 'warning' })
            }
        },
        hasRoute(path, routeList) {
          !routeList && (routeList = this.routeList, console.log('执行'))
          console.log(routeList)
          for (let i = 0; i < routeList.length; i++) {
            console.log(routeList[i].path)
            if (routeList[i].path == path) {
              return true
            }
            if (routeList[i].children) {
              let flag = this.hasRoute(path, routeList[i].children)
              if(flag){
                return flag
              }
            }
          }
          return false
        },
        //接收
        handleJieshouTap() {


            if (this.ids != undefined && !this.multiple) {
                this.$modal.confirm('是否确认接收所选数据数据项？').then(function () {
                }).then(() => {
                    jieshou({
                        categoryId: this.queryParams.categoryId,
                        ids: this.ids
                    }).then(res => {
                        this.getlistPost();
                        this.$modal.msgSuccess("接收成功");
                        setTimeout(res => {
                            getDicts_archive('JUMP_ADDRESS').then(response => {
                                console.log(response,"ksdfjklsdj")
                                var url = response.data.filter(res => { return res.dictValue == "WJZL" })

                                if(url.length>0){
                                    this.$router.push({ path: url[0].dictLabel })
                                }

                            })

                        }, 1000)
                    })

                }).catch(() => { });
            } else {
                this.$message({ message: '请选择要接收的数据哦', type: 'warning' })
            }
        },
        handleJieshouTap2() {
            if (this.ids != undefined && !this.multiple) {
                this.$modal.confirm('是否确认接收所选数据数据项？').then(function () {
                }).then(() => {
                    jieshou2({
                        categoryId: this.queryParams.categoryId,
                        ids: this.ids
                    }).then(res => {
                        this.getlistPost();
                        this.$modal.msgSuccess("接收成功");
                    })

                }).catch(() => { });
            } else {
                this.$message({ message: '请选择要接收的数据哦', type: 'warning' })
            }
        },

        //双击列表进入详情页面
        celldblclick(row) {
            var level = "";
            var label = "";
            if (getLastIndexOf(this.queryParams.sub_table_name) == "F") {  //F 件
                level = 0
                label = row.TITLE;
            } else if (getLastIndexOf(this.queryParams.sub_table_name) == "V") { //卷
                level = 1
                label = row.TITLE;
            } else { //项目
                level = 3
                label = row.XMMC;
            }
            this.celldbData = {
                id: row.ID,
                categoryId: this.queryParams.categoryId,
                menuId: this.queryParams.menuId,
                sub_table_name: this.queryParams.sub_table_name,
                label: this.queryParams.label,
                level: level,
                ifSub_table_name: this.queryParams.sub_table_name,
                isDel: "0",  //判断是回收站数据还是接收收据 isDel:1  回收站    isDel:0 //离线接收、档案接收、在线接收
                tableHeaderList: this.tableHeaderList
            }
            this.$nextTick(() => {
                if (this.subStr == "F") {  //F 进入件详情
                    this.jianDetailsOpen = true;
                } else { //进入卷详情 和项目详情
                    this.juanDetailsOpen = true
                }
            })
        },
        //关闭详情页面
        detailsHandleClose() {
            this.jianDetailsOpen = false;
            this.juanDetailsOpen = false;
        },

        //排序
        sortChange(val) {
            // console.log(val, "ksdfjkl")
            this.queryParams.order = val;
            // console.log(this.queryParams, "+++")
            this.getlistPost();
        },

        // 案件信息
        handleInfoDetailTap() {
            if (this.ids == undefined || this.ids.length == 0) {
                this.$message({ message: '请选择要查看案件信息的数据哦', type: 'warning' })
                return false
            }
            if (this.single) {
                this.$message({ message: '请选择一条要查看案件信息的数据哦', type: 'warning' })
                return false
            }
            this.info.open = true
            this.$nextTick(() => {
                this.$refs.infoRef.init(this.ids, this.queryParams.categoryId)
            })
        },
        // 关闭案件信息弹窗
        infoCancelTap() {
            this.info.open = false
        },

        //组卷 合并卷
        mergeYqdaTap(val) {
            if (this.ids != undefined && !this.multiple) {
                if (val == 1) {
                    var IDS = this.ids.split(",")
                    var datas = [];
                    for (var i in this.tableData) {
                        for (var j in IDS) {
                            if (this.tableData[i].ID == IDS[j]) {
                                if (this.tableData[i].IS_ZUJUAN == 1) {
                                    datas.push(this.tableData[i].TITLE)
                                }
                            }
                        }
                    }
                    if (datas.length > 0) {
                        this.$message({ message: '选择的数据已经组卷', type: 'warning' })
                        return
                    }
                    this.openInfo = {
                        opens: true,
                        categoryId: this.queryParams.categoryId,
                        menuId: this.queryParams.menuId,
                        folderId: undefined, //组卷id
                        itemId: undefined, //项目Id
                        subTableName: this.queryParams.sub_table_name,
                        nodeType: this.queryParams.nodeType,
                        parentNodeType: this.queryParams.parentNodeType,
                        parentSubTableName: this.queryParams.parentSubTableName,
                        subStr: this.subStr,
                        type: 1,
                        ids: this.ids,
                        isDisabled: val //判断如果从组卷按钮和合并卷按钮进去带参isDisabled，只可以将件组成卷或者将多个卷里面的件合并，不可以在里面添加件
                    }
                    this.juanOpen = true;
                }
            } else {
                this.$message({ message: '请选择要操作的数据哦', type: 'warning' })
            }
        },
        // 上传前校检格式和大小
        handleBeforeUpload(file) {
            // 校检文件类型
            const extension = file.name.substring(file.name.lastIndexOf('.') + 1);
            if (extension !== 'zip') {
                this.$message.warning('只允许上传zip格式的文件')
                return false
            }
            this.$modal.loading("正在上传文件，请稍候...");
            return true;
        },
        // 上传失败
        handleUploadError(err) {
            this.$modal.msgError("上传文件失败，请重试");
            this.$modal.closeLoading()
        },
        // 文件个数超出
        handleExceed() {
            //this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
        },
        uploadFileUrl(concent, currentChunk) {
            // 分片处理
            // const chunkSize = 20 * 1024 * 1024; // 每个片段的大小，这里是20MB
            concent.file.chunkSize = this.chunkSize;
            console.log("chunkSize", this.chunkSize)
            const totalChunks = Math.ceil(concent.file.size / (this.chunkSize * 1024 * 1024)); // 总片段数
            console.log("totalChunks", totalChunks)
            concent.file.chunks = totalChunks; // 将总片段数保存到file对象中
            let uploaded = 0 // 已上传块数
            /*return this.calculateMD5(concent.file)
              .then(md5 => {*/
            let time = new Date().getTime();
            let name2 = concent.file.name;
            let index = name2.lastIndexOf(".");
            name2 = name2.substring(0, index) + time + name2.substring(index, name2.length);
            // 将文件切分为多个片段
            const chunks = [];
            for (let i = 0; i < totalChunks; i++) {
                const start = i * this.chunkSize * 1024 * 1024;
                const end = Math.min(start + this.chunkSize * 1024 * 1024, concent.file.size);
                // chunks.push(concent.file.slice(start, end));
                chunks.push(
                    new Promise((resolve, reject) => {
                        const formData = new FormData();
                        formData.append("file", concent.file.slice(start, end), name2);
                        formData.append("chunk", i + 1);
                        //formData.append("type",this.menuName.includes("大事记")?1:2);  // 1 大事记 2 组织沿革
                        formData.append("modeEnum", "RANDOM_ACCESS");
                        formData.append("categoryId", this.queryParams.categoryId);
                        //formData.append("chunkSize", concent.file.chunkSize); //分片大小
                        formData.append("chunkSize", this.chunkSize); //分片大小
                        formData.append("chunks", concent.file.chunks); // 总分片数
                        //console.log(concent.file.chunkSize,"-----");
                        //console.log(concent.file.chunks,"=====");
                        formData.append("md5", this.userId + '_' + new Date().getTime()); // md5值
                        fileUpload(formData).then(response => {
                            resolve(response); // 将上传结果传递给 Promise 的 resolve
                        }).catch(error => {
                            reject(error); // 将错误信息传递给 Promise 的 reject
                        });
                    })
                )
            }
            return Promise.all(chunks).then(responses => {
                this.$modal.closeLoading();
                this.getlistHeaderPost();
            }).catch(error => {
                console.error("错误:", error);
                throw error; // 抛出错误，以便后续可以捕获并处理
            }); // 等待所有分片上传完成
            /*})
            .then(responses => {
              this.$modal.closeLoading();
              this.getList();
            })*/

        },
      /**四性检测方案列表 */
      getdetectionSchemeListPOST() {
        getdetectionSchemeList({
          state: "1",
          phase: "4",
          categoryId: this.queryParams.categoryId,
        }).then(res => {
          if (res.rows.length > 0) {
            this.sxjcList = res.rows
            this.dialogVisible = true;
          } else {
            this.$message({ message: '当前门类数据还没有四性检测方案数据', type: 'warning' })
          }
        })
      },
      handleSXJCTap() {
        if (!this.multiple) {
          this.dialogVisible = true;
          this.getdetectionSchemeListPOST();
        } else {
          this.$message({ message: '请选择要检测的数据哦', type: 'warning' })
        }
      },

      //选择检测方案
      handleYes() {
        if (this.sxjcType == undefined) {
          this.$message({ message: '请选择方案', type: 'warning' })
          return false
        }
        if (this.subStr == 'X') {
          this.daType = 3
        } else if (this.subStr == 'V') {
          this.daType = 1
        } else if (this.subStr == 'F') {
          this.daType = 0
        }
        var dataArr = {
          "categoryId": this.queryParams.categoryId,
          "link": "4",
          "code": this.sxjcType,
          "daIds": this.ids,
          // "menuType": this.menuType,
          "daType": this.daType
        }
        this.$modal.loading("正在检测中...");
        this.dialogVisible = false;
        ygdDetection(dataArr).then(res => {
          if (res.code == "200") {
            this.$modal.msgSuccess("检测成功")

            this.sxjcType = undefined;
            this.getlistHeaderPost();
            this.$modal.closeLoading();
          }
        }).catch(res => {
          this.$modal.msgSuccess("检测失败")
          this.sxjcType = undefined;
          this.getlistHeaderPost();
          this.$modal.closeLoading();
        })


      },

      handlecloseDelDialog() {
        this.sxjcType = undefined
        this.dialogVisible = false
      },
    }
}
</script>
